package com.woniuxy01;

import java.util.Arrays;

/**
 * @author 作者
 * @create 2025-09-09 10:47
 */
public class Test02 {
    public static void main(String[] args) {


    }

    private static void test12() {
        String str = "             aaaa            ";
        System.out.println(str);
        System.out.println(str.trim());
        System.out.println("daa".compareTo("acaa"));
    }

    private static void test11() {
        String str = "abxyzcdexyzfghixyzajka";
        System.out.println(str);
        System.out.println(str.replace('a', 'm'));
        System.out.println(str.replace("xyz", "jkl"));
    }

    private static void test10() {
        String str = "abcABC";
        System.out.println(str.toUpperCase());
        str = str.toUpperCase();
        System.out.println(str);

        str = str.concat("xxxxxxxxxxxx");
        System.out.println(str);
    }

    private static void test09() {
        String str = "aaa";
        System.out.println(str.toUpperCase());
        System.out.println(str.toUpperCase().toLowerCase());

        str = str + "bbb";
        System.out.println(str);

        str = str.concat("ccc");
        System.out.println(str);
    }

    private static void test08() {
        char[] chars = {'a', 'b', 'c'};
//        String str="";
//        for(char c:chars){
//            str+=c;
//        }
//        System.out.println(str);

        String str1 = String.valueOf(chars);
        System.out.println(str1);
        String str2 = new String(chars);
        System.out.println(str2);

        int i = 5;
        String str3 = String.valueOf(i);
        System.out.println(str3);
        String str4 = i + "";
        System.out.println(str4);
    }

    private static void test07() {
        String str = "ab中文";
        byte[] bytes = str.getBytes();
        System.out.println(Arrays.toString(bytes));
        char[] chars = str.toCharArray();
        System.out.println(Arrays.toString(chars));
    }

    private static void test06() {
        String str = "abcdefg";
        System.out.println(str.substring(2));
        System.out.println(str.substring(2, 5));
        System.out.println(str.substring(2, str.length()));
    }

    private static void test05() {
        String str = "axyzabcxyzdefgxyz";
        System.out.println(str.isEmpty());
        System.out.println(str.length());
        System.out.println(str.charAt(0));
        System.out.println(str.charAt(1));
        System.out.println(str.charAt(2));
        System.out.println(str.indexOf('x'));
        System.out.println(str.indexOf('z'));
        System.out.println(str.indexOf("xy"));
        System.out.println(str.indexOf("xyz"));
        System.out.println(str.indexOf('a'));
        System.out.println(str.indexOf(97));
        System.out.println(str.indexOf('a'));
        System.out.println(str.indexOf('a', 0));
        System.out.println(str.indexOf('a', 1));
        System.out.println(str.indexOf('m'));
    }

    private static void test04() {
        String str = "";
        System.out.println(str.isEmpty());
        String str2 = " ";
        System.out.println(str2.isEmpty());
        String str3 = new String("");
        System.out.println(str3.isEmpty());
    }

    private static void test03() {
        String str1 = "abc";
        String str2 = "AbC";
        //比较密码:区分带小写
        System.out.println(str1.equals(str2));
        //验证码：忽略大小写
        System.out.println(str1.equalsIgnoreCase(str2));
        // 65A  66B   97a  98b

        System.out.println("abcdefg".contains("abc"));
        System.out.println("abcdefg".contains("bcd"));
        System.out.println("abcdefg".contains("bcxd"));

        System.out.println("abcdefg".startsWith("abc"));
        System.out.println("abcdefg".startsWith("bc"));
        System.out.println("abcdefg".endsWith("fg"));
        System.out.println("abcdefg".endsWith("xfg"));
    }

    private static void test02() {
        String s1 = "aaa";
        String s2 = "aaa";
        System.out.println(s1 == s2);
        System.out.println(s1.equals(s2));

        String s3 = new String("aaa");
        String s4 = new String("aaa");
        System.out.println(s3 == s4);
        System.out.println(s3.equals(s4));
        System.out.println(s3);
        s3 = "bbb";
        System.out.println(s3);
    }

    private static void test01() {
        String s1 = "aaa";
        String s2 = new String("aaa");
        System.out.println(s1);
        System.out.println(s2);
        s1 = "bbb";
        s2 = "ccc";
        System.out.println(s1);
        System.out.println(s2);
    }
}
